<template>
	<el-card shadow="hover" header="测试图表">
		<scEcharts height="210px" :option="option5"></scEcharts>
	</el-card>
</template>

<script>
import scEcharts from '@/components/scEcharts';
export default {
	components: {
		scEcharts
	},
	data() {
		return {
			option5: {title: {
					text: '测试图表文字',
				},},
			timer:null
		}
	},
	created() {
		clearInterval(this.timer)
		this.timer = null
	},
	beforeUnmount() {
		clearInterval(this.timer);
		this.timer = null
	},
	mounted() {
		this.getUserWorkForBar();
		this.setTimer();
	},
	methods: {
		async getUserWorkForBar()
		{
			let res = await this.$API.bpm.echarts.getUserWorkForBar.get();
			if (res.code === 200) {
				this.option5 = res.data;
			} else {
				this.$alert(res.message, "提示", {type: 'error'})
			}
		},
		setTimer() {
			if(this.timer == null) {
				this.timer = setInterval( () => {
					this.getUserWorkForBar();
				}, this.$TOOL.data.get("MSG_TIME"))
			}
		}
	}
}
</script>
